package C7_7_IntroduceForeignMethod;

import java.util.Date;

/**
 * 引入外加函数
 */
public class AddForeginMethod {

    public Date getNewDate() {
        Date previousEnd = new Date();
        Date newStart;
        //重构前
        newStart = new Date(previousEnd.getYear(), previousEnd.getMonth(), previousEnd.getDate() + 1);
        //重构后
        newStart = nextDay(previousEnd);

        return newStart;
    }

    private static Date nextDay(Date arg){
        return new Date(arg.getYear(), arg.getMonth(), arg.getDate() + 1);
    }

}
